<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file ="../include/base.jsp"%>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
	<meta charset="UTF-8">
	<link rel="stylesheet" type="text/css"  href="<%=basePath %>css/bootstrap.min.css"/>
	<link rel="stylesheet" type="text/css"  href="<%=basePath %>css/task.css"/>
	<title>凯胜项目管理系统</title>
	<style type="text/css">
		body{
			padding-top:50px;
		}
		.mywell{
			margin-top:25px;
		}
		
	</style>
</head>
<body class="body">
	
	<%@ include file = "../include/sametop.jsp" %>
	<div class="container">
		<div class="row">
		<jsp:include page="../include/sameleft.jsp">
			<jsp:param value="deal" name="tag"/>
		</jsp:include>
			<div class="span9">
			
		<div class ="span9" style = "margin-top:25px">
				<ul class="breadcrumb" style="height:30px;margin-bottom:0px;border-radius:3px 3px 0 0;border:1px solid #dddddd"">
					<li class="active" style="margin-top:8px">
						<a href="task.html" style="font-size:16px"><i class="icon-plus"></i>编辑交易</a>
						
					</li>
					<li style = "float:right">
					<span style = "color:#08c">搜索交易:</span><input type="text" value = "搜索交易" style="color:#cccccc;border-radius:10px 10px" />、 
					 
					</li>
					<li style="float:right"></li>
				</ul>
				<div class="wall" style="border-top:none; border:1px solid #dddddd;">
					<div style = "margin-top:20px;margin-left:80px;">
					<form action = "<%=basePath%>deal/update.action" method = "post">
					<input type ="hidden" value="${deal.progress}" name="deal.progress">
					  <fieldset>
						<div class="control-group">

						   <label class="control-label" for="input01"><strong>交易人姓名</strong></label>
						   <input type="hidden" name="deal.id" class="input-xlarge"   value="${deal.id }">
							<input type="hidden" name="contactid" class="input-xlarge"  id="searchhidden" value="">
						  <div class="controls mycon">
						  
							<input style ="width:250px"type="text" name = "deal.contactname" class="input-xlarge" id="searchContact" value="${deal.contactname}">
							
							<div class = "input-xlarge show" style = "display:none;width:250px;margin-top:0px;border-radius: 3px;border: 1px solid #CCC;background-color:#ffc">
							</div>

							<p class="help-block mytip">*填入或搜索与这笔交易相关的人或者是公司</p>
						  </div>
						</div>
						<div class="control-group">

						   <label class="control-label" for="input01"><strong>交易的名字</strong></label>
						  <div class="controls ">
						  
							<input type="text" name="deal.name" class="input-xlarge" id="input01" value="${deal.name }">
							
							<p class="help-block">*给这笔交易写个名字</p>
						  </div>
						</div>
						<div class="control-group">

						   <label class="control-label"  for="input01"><strong>交易的描述</strong></label>
						  <div class="controls">
						  
							<textarea  name = "deal.background" id="input01" style = "width:400px;height:100px">${deal.background}</textarea>
							
						  </div>
						   </div>
						  <div class="control-group">

						   <label class="control-label" for="input01"><strong>总金额</strong></label>
						  <div class="controls">
							<input type="text" style = "width:150px" name = "deal.price" value="${deal.price }"/>￥
							<!--<select name="" id="" style = "width:80px">
								<option value="">固定</option>
								<option value="">每小时</option>
								<option value="">每月</option>
								<option value="">每年</option>
							
							</select>
							
						  --></div>
						  
						</div>
						<div class="control-group">

						  <label class="control-label" for="input01"><strong>类别</strong></label>
						  <div class="controls">
							<select name="deal.priceChangeState" id="" >
								<option value="${deal.priceChangeState }">${deal.priceChangeState }</option>
								<option value="固定">固定</option>
								<option value="每小时">每小时</option>
								<option value="每月">每月</option>
								<option value="每年">每年</option>
							</select>
						  </div>
						   </div>
						   <div class="control-group">

						  <label class="control-label" for="input01"><strong>设置权限</strong></label>
						  <div class="controls">
						  		<input type="hidden" value="${deal.views }" class="myviews"/>
						  		<input type ="radio"  name = "deal.views" value="all" id="all" >所有人 <br/>
								<input type ="radio" name = "deal.views"  value="me" id="me">只有我<br/>
								<input type ="radio" id = "radiobtn" value="all,other" id="other">我,和下面这些人<br/>
						  	
						  
							
							<div id="showSelect" style="display:none">
							<select name=""  >
								<option value="">请选择</option>
								<option value="">张三</option>
								<option value="">王五</option>
								<option value="">李四</option>
								<option value="">小妹</option>
							</select>
							</div>
						  </div>
						   </div>
						   
						   <hr />
						   <div style = "margin-left:100px;margin-top:40px">
							<button class = "btn btn-success">保存</button>
						   <button class = "btn ">取消</button>
							
							
						 
						   </div>
						   
					  </fieldset>
					  
					</form>
					
				</div>
			
				</div>
	</div>
	<script type="text/javascript" src="http://lib.sinaapp.com/js/jquery/1.7.2/jquery.min.js"></script>
	<script type="text/javascript" src="http://lib.sinaapp.com/js/bootstrap/2.0.3/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="<%=basePath %>js/jquery.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			var v = $(".myviews").attr("value");
			
			var m = $("#all").attr("value");
			var n = $("#me").attr("value");
			var q = $("#other").attr("value");
			
			if(v=="all"){
				$("#all").attr("checked", true);

			
			}
			if(v=="me"){
				$("#me").attr("checked", true);

			
			}
			if(v=="all,other"){
				$("#other").attr("checked", true);
			
			}
			
			$("#radiobtn").click(function(){
				$("#showSelect").show();
			});
			$("#searchContact").live("keyup",function(){
					var v = this.value;
					
					if(v.length>0){
					
						$.get("<%=basePath%>contact/search.action?q_pinyin="+v,function(data){
							$(".show").show();
							
							if(data.length == 0){
								$(".show").empty();
								$(".show").append($("<span>没有适合的人选</span>"));
							}else{
								//情况div中元素
								$(".show").empty();
								$(".show").append($("<ul class='nav nav-list myul'><li style ='margin-top:25px'></li><li>点击你想要选的人</li></ul>"));
								for(var i=0;i<data.length;i++){
									$(".myul").append($("<li class = 'myli' id = "+data[i].type+"><a href = 'javaScript:;' class ='mya' id="+data[i].id+">"+data[i].name+"</a></li>"));
								
								}
							
							
							}
							/* alert(data);
							alert(data[0].id); */
					
					
					
						}); 
					}
					
				
				
				});
				$(".mya").live("click",function(){
					var v = $(this).html();
					var id = $(this).attr("id");
					alert(id);
					var type = $(this).parent().attr("id");
					$("#searchContact").attr("value",v);
					$("#searchhidden").attr("value",id);
					$(".show").hide();
					$("#searchContact").hide();
					$(".mytip").hide();
					if(type =='company'){
						$(".mycon").append($("<div style = 'margin-bottom:40px'><img style = 'width:30px;height:30px;' src='<%=basePath%>img/Company-icon.png'/><div style = 'margin-left:50px;margin-top:-30px;'>"+v+"</div></div>"));
					
					}
					if(type =='person'){
						$(".mycon").append($("<div id = 'mimg' style = 'margin-bottom:40px'><img style = 'width:30px;height:30px;' src='<%=basePath%>img/3.png'/><div style = 'margin-left:50px;margin-top:-30px;'>"+v+"<br/><a href='javaScript:;' id = 'select'>选择别人</a></div></div>"));
					
					}
				});
				$("#select").live("click",function(){
					$(".mycon").empty();
					$(".mycon").append($("<input style ='margin-bottom:0px;width:250px'type='text' name = '' class='input-xlarge' id='searchContact'><div class = 'input-xlarge show' style = 'display:none;width:250px;margin-top:0px;border-radius: 3px;border: 1px solid #CCC;background-color:#ffc'>"));
					$(".mytip").show();
				
				
				});
		});
		
	</script>
</body>
</html>
